package testElasticsearch;

import java.net.InetAddress;
import java.net.UnknownHostException;

import org.elasticsearch.action.admin.cluster.health.ClusterHealthRequest;
import org.elasticsearch.action.admin.indices.create.CreateIndexRequest;
import org.elasticsearch.client.Client;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.transport.InetSocketTransportAddress;

public class testElasticsearch {

	public static void main(String[] args) {
		Settings settings = Settings.settingsBuilder().put("cluster.name", "lpdb_test").build();
		Client client = null;
		try {
			client = TransportClient.builder().settings(settings).build().addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("192.168.3.81"),9301));
		} catch (UnknownHostException e) {
			e.printStackTrace();
		}
		
		client.admin().indices().create(new CreateIndexRequest("test2")).actionGet();  

        // waitForYellow  

        client.admin().cluster().health(new ClusterHealthRequest("test2").waitForYellowStatus()).actionGet();


	}

}
